﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.Diagnostics
{


    /// <summary>
    /// UDP组播,可以用于日志打印,
    /// </summary>
    public class UdpGroupSend
    {
        /// <summary>
        /// 组播地址与端口
        /// </summary>
        public System.Net.IPEndPoint ep = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("239.239.239.239"), 22222);
        System.Net.Sockets.UdpClient udpClient = new Net.Sockets.UdpClient();

        /// <summary>
        /// 发送到数据中
        /// </summary>
        /// <param name="str"></param>
        public void SendStrGB2312(string str)
        {
            System.Diagnostics.Debug.WriteLine(str);
            byte[] buff = System.Text.Encoding.GetEncoding("GB2312").GetBytes(str);
            udpClient.Send(buff, buff.Length, ep);

        }
    }

    /// <summary>
    /// UDP组播
    /// </summary>
   public class UDPGroup
    {



       //public static SocketBroadcast group = null;
public static UdpGroupSend group =new  UdpGroupSend();

       /// <summary>
       /// 发送到数据中
       /// </summary>
       /// <param name="str"></param>
       public static void SendStrGB2312(string str)
       {

           //System.Console.WriteLine(str);
           group.SendStrGB2312(str);
       }
   }
}
